<?php

    require ( 'init.inc.php' );
    require ( 'checkadmin.inc.php');
    require ( __COMM_PATH . 'pagecontrol.inc.php' );
    require ( __CLASS_PATH . 'page_list.class.php' );
   // require ( __CLASS_PATH . 'tree.class.php' );
    
	
	
    // -------------------------------------------------------
    // 接收传递过来的变量
    // -------------------------------------------------------
    $action = $_REQUEST["action"];
    $id = addslashes($_REQUEST["id"]);
    $keyword = addslashes(substr($_REQUEST["keyword"], 0, 30));
    // -------------------------------------------------------
    // 批量操作
    // -------------------------------------------------------
   if (!empty($id)) {
        switch ($action) {
            case "del" : $db->query("delete from `{$tablepre}coupon` where id in ({$id})");
						  file_log($_SESSION['AdminUser'],"删除优惠券");
						  break;
            case "confirm" : $db->query("update`{$tablepre}coupon` set `status`=1 where id in ({$id})");
							  file_log($_SESSION['AdminUser'],"修改优惠券状态");
						      break;
            case "deconfirm" : $db->query("update`{$tablepre}coupon` set `status`=0 where id in ({$id})");
			                   file_log($_SESSION['AdminUser'],"修改优惠券状态");
						       break;
        }
    }

 
    // -------------------------------------------------------
    // 页面基本设置
    // -------------------------------------------------------
   $page_title   = $ptitle["sales_excel"];
    $page_size    = 15;
    $display_page = "sales_excel.htm";
    $keyword      = addslashes(substr($_REQUEST["keyword"], 0, 30));
    $sortby       = "id";
    $oexp         = "desc";
	if($keyword){
		$sel_sql="select `id`,`couponpwd`,`couponval`,`coupontim`,`status` from `{$tablepre}coupon` where `couponpwd`='$keyword' ";
	}else{
		$sel_sql="select `id`,`couponpwd`,`couponval`,`coupontim`,`status` from `{$tablepre}coupon` ";
		}
	/*  $search_arr[] = array (
                        "field" => "couponpwd",
                        "keyword" => urldecode($keyword),
                        "condition" => "like",
                        "junk" => "or"
                    );
    $search_junk  = "or";*/
 /*
    //$query_sql    = "select * from `{$tablepre}products_daili` where products_classid={$classid}";
    $query_sql    = "select C.class_name,S.* from `{$tablepre}products_daili` as S, `{$tablepre}products_class` as C where S.products_classid=C.id";
    if ($classid>0) $query_sql .= " and S.products_classid =$classid";
    //echo $query_sql;
    $url_para_arr = array ('classid','keyword');
    $tpl->assign("products_search", $ptitle["products_search"]);

     // -------------------------------------------------------
    // 其他处理 (生成下拉列表)
    // -------------------------------------------------------
    $tree = new Tree("{$tablepre}products_class",0);
    $tpl->assign('products_classid_box', $tree ->_makeSelBox("products_classid",$classid,true,"location.href='?classid='+this.value;"));

    // -------------------------------------------------------
    // 执行页面处理
    // -------------------------------------------------------
	*/
	
    show_page_head("list",$page_title);
    $plist = new PageList($page_title, $page_size);
    //$plist->SetSearch($search_arr, $search_junk);
    $plist->SortOpen = true;
    $plist->SetSort($sortby, $oexp);
    $plist->SetUrlParam($url_para_arr);
    $plist->Execute($sel_sql);
    $plist->TplParse($display_page);
	//$tpl->assign("classid",$classid);
    show_page_foot();
    $db->close();
?>